<template>
  <Container class="user-edit">
    <div class="user-main">
      <div class="left">
        <div class="bg-light">
          <div class="container-title">平台信息</div>
          <div class="info-one">
            <ul class="row one">
              <li v-for="(item, index) of bottomList" :key="index">
                <img :src="item.url" alt="">
              </li>
            </ul>
            <ul class="row two">
              <li v-for="(item, index) of swiperList" :key="index">
                <img :src="item.url" alt="">
              </li>
            </ul>
          </div>
        </div>
        <div  class="bg-light mt info-two">
          <div v-for="item in integral" :key="item.id" @click="jumpPage(item.path)">
            <div class="l">
              <img :src="item.pic" alt="">
            </div>
          </div>
        </div>
      </div>
      <div class="right mt">
        <img :src="info" alt="">
      </div>
    </div>
    <ViewModalItem ref="view"></ViewModalItem>
  </Container>
</template>

<script>
import table from '@/table'
import { mapGetters } from 'vuex'
import ViewModalItem from './edit/ViewModalItem'
export default {
  components: {
    ViewModalItem
  },
  data () {
    return {
      options: {
        tableHeight: 300
      },
      supplierName: '',
      mobile: '',
      realName: '',
      loginIp: '',
      loginDate: '',
      email: '',
      headers: {},
      showAd: false,
      info: require("../../../assets/images/yygs/gywm_0.png"),
      swiperList: [{
        id: 0,
        type: 'image',
        url: 'https://www.yybxk.net/images/sw01.png'
      }, {
        id: 1,
          type: 'image',
          url: 'https://www.yybxk.net/images/sw02.png',
      }, {
        id: 2,
        type: 'image',
        url: 'https://www.yybxk.net/images/sw03.png'
      }],
      bottomList: [ {
        id: 4,
        type: 'image',
        url: 'https://www.yybxk.net/images/sw04.png'
      }, {
        id: 4,
        type: 'image',
        url: 'https://www.yybxk.net/images/sw05.png'
      }],
      integral: [{
        class: 'red',
        pic: require('../../../assets/images/yygs/dndl_1.png'),
        name: '好胎送礼兑换统计',
        path: '0'
      }, {
        class: 'yellow',
        pic: require('../../../assets/images/yygs/fwzx_1.png'),
        name: '1-2月抢好胎送豪礼',
        path: '1'
      }, {
        class: 'blue',
        pic: require('../../../assets/images/yygs/dzfw_1.png'),
        name: '3-4月抢好胎送福券',
        path: '2'
      }, {
        class: 'yellow',
        pic: require('../../../assets/images/yygs/cjwt_1.png'),
        name: '4-5月抢好胎送豪礼',
        path: '3'
      }, {
        class: 'yellow',
        pic: require('../../../assets/images/yygs/gywm_1.png'),
        name: '4-5月抢好胎送豪礼',
        path: '4'
      }, {
        class: 'yellow',
        pic: require('../../../assets/images/yygs/jmzs_1.png'),
        name: '4-5月抢好胎送豪礼',
        path: '5'
      }]
    }
  },
  mounted () {
    // this.list.currentPage = ~~this.$route.query.currentPage || 1
    // this.list.pageSize = ~~this.$route.query.pageSize || this.list.pageSize
    // this.initTable()
    // this.showAdData()
    // this.setHeader()
    // this.getUserData()
    // this.getLogData()
  },
  methods: {
    ...table,
    setHeader () {
      let userToken = this.user.userToken
      if (userToken) {
        this.headers['Authorization'] = 'Bearer ' + `${userToken}`
      }
    },
    showAdData () {
      this.$ajaxGet('/common/is_tire').then(data => {
        this.showAd = data
      })
    },
    getUserData () {
      this.$ajaxGet('/supplier/supplier_user/find_admin').then(data => {
        this.supplierName = data.supplierName
        this.mobile = data.mobile
        this.realName = data.realName
        this.loginDate = (data.loginDate).replace('T', ' ')
        this.loginIp = data.loginIp
        this.email = data.email
      })
    },
    getLogData () {
      this.list.status = 'loading'
      let param = {
        size: this.list.pageSize,
        current: this.list.currentPage
      }
      this.$ajaxGet('/supplier/user_login_log/page', param).then(data => {
        this.list.data = (data.records || []).map(item => {
          return {
            createDate: item.createDate,
            ip: item.ip,
            area: item.area,
            equipment: item.equipment
          }
        })
        this.list.totalItem = Number(data.total)
        this.list.currentPage = Number(data.current)
        this.backTableTop()
        this.list.status = 'pass'
      }).catch(() => {
        this.list.status = 'error'
      })
    },
    onPageChange (number) {
      this.list.currentPage = number
      this.$router.push({
        query: {
          currentPage: this.list.currentPage,
          pageSize: this.list.pageSize
        }
      })
      this.getLogData()
    },
    onPageSizeChange (pageSize) {
      this.list.currentPage = 1
      this.list.pageSize = pageSize
      this.$router.push({
        query: {
          currentPage: this.list.currentPage,
          pageSize: this.list.pageSize
        }
      })
      this.getLogData()
    },
    jumpPage (path) {
      this.$refs.view.openModal(path)
    }
  },
  computed: {
    ...mapGetters(['user'])
  }
}
</script>
